package com.example.demo.controller;


import com.example.demo.entity.User;
import com.example.demo.service.IUser;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RequestMapping("/test")
@RestController
public class TestController {

    @Resource
    IUser userService;



    @GetMapping("/list")
    public List<User> list(){
        return userService.list();
    }

    @PostMapping("save")
    public String save(@RequestBody User user){
        userService.save(user);
        return "保存成功";
    }


    @PutMapping("/update")
    public String update(@RequestBody User user){
        userService.update(user);
        return "修改成功";
    }


    @DeleteMapping("/deleted")

    public String deleted(Integer id){
        userService.deleted(id);
        return "删除成功";
    }


}
